@extends('common.base-master')

@section('html-head')
    <link href="{{url('css/createFacilitator.css')}}" type="text/css" rel="stylesheet"/>
    <script src="{{url('js/createPop.js')}}"></script>
@endsection

@section('html-body')
    <main>
        <section class="banner createPop">
            <div style="background: none;">
                <p class="title">手有成功单，<em class="color">薪资皆浮云</em></p>
                <p class="desc">想要成为高薪资推广员？加入Wike吧！</p>
            </div>
        </section>
        <section style="height: 330px;@if($facInfo && $facInfo->t_state == 0)display: none; @else display: block; @endif">
            <div style="text-align: center">
                您已提交了认证，请到 <a href="{{route('Home.Service.userCenter')}}" style="color:darkcyan;cursor:hand; text-decoration:underline">[管理中心]</a> 修改资料
            </div>
        </section>
        <section class="tableBox" @if($facInfo && $facInfo->t_state != 0)style="display: none;" @else style="display: block;" @endif>
            <div class="first" style="display: block;">
                <ul>
                    <form id="setPopInfo">
                    <li class="code">
                        <em>Wike邀请码</em>
                        <input type="text" name="invite" placeholder="如果您有邀请人，可输入他的邀请码"/>
                        <em class="code_error error"></em>
                    </li>
                    <li class="real_name"><em>真实姓名</em><input type="text" name="realname" value="{{$facInfo->realname}}" /><em class="realName_error error"></em></li>
                    <li class="contact"><em>联系电话</em><input type="text" name="telephone" value="{{$facInfo->telephone}}" /><em class="contact_error error"></em></li>
                    <li class="qq"><em>联系QQ</em><input type="text" name="qq" value="{{$facInfo->qq}}" /><em class="qq_error error"></em></li>
                    <li class="email"><em>联系邮箱</em><input type="text" name="email" value="{{$facInfo->email}}" /><em class="email_error error"></em></li>
                    <li class="id"><em>身份证号</em><input type="text" value="{{$facInfo->card_num}}" /><em class="id_error error"></em></li>
                    <li class="identityCard">
                        <em>身份证号上传</em>
                        <div>
                            <P>
                                <a href="javascript:void(0)" id="cardfBtn" ><span id="cardf_cue">上传您的身份证正面</span></a><br />
                                <em class="prompt">上传文件大小不能超过1m 支持png，jpg格式</em>
                                <input type="hidden" name="cardf_id" id="cardf_id" value="{{$facInfo->img_cardf_id}}" />
                            </P>
                            <P>
                                <a href="javascript:void(0)" id="cardbBtn"><span id="cardb_cue">上传您的身份证背面</span></a><br />
                                <em class="prompt">上传文件大小不能超过1m 支持png，jpg格式</em>
                                <input type="hidden" name="cardb_id" id="cardb_id" value="{{$facInfo->img_cardb_id}}" />
                            </P>
                        </div>
                        <input type="hidden" name="t_state" value="1" />
                    </li>
                    </form>
                </ul>
                <div class="idCard">
                    <img id="cardf_img" src="{{route('Api.Cardf.Show',['id'=>$user->id])}}" class="front" /><img id="cardb_img" src="{{route('Api.Cardb.Show',['id'=>$user->id])}}" class="after" />
                </div>
                <p class="next"><button class="submit">申请入驻</button></p>
            </div>
        </section>
    </main>
    <script>
        var Home = "{{route('Home')}}";
        var setFacInfoUrl = "{{route('Api.Fac.setUserInfo')}}";
        var uploader = new plupload.Uploader({
            runtimes: 'html5,flash,silverlight,html4',
            browse_button: 'cardfBtn',
            url: '{{url('api/upload/image')}}',

            chunk_size: '20mb',
            filters: {
                max_file_size: '10mb',
                mime_types: [
                    {title: "Image files", extensions: "jpg,gif,png"}
                ],
                prevent_duplicates: false
            },
            multi_selection: true,
            unique_names: true,

            flash_swf_url: '{{ url('vendor/plupload-2.1.2/Moxie.swf') }}',
            silverlight_xap_url: '{{ url('vendor/plupload-2.1.2/Moxie.xap') }}',

            file_data_name: 'photo',
            headers: {
                Accept: 'application/json'
            },

            multipart_params: {
                _token: '{{ csrf_token() }}'
            },

            init: {
                PostInit: function () {
                },

                FilesAdded: function (up, files) {
                    up.start();
                },

                BeforeUpload: function (up, file) {
                    up.settings.multipart_params.file_name = file.name;
                },

                UploadProgress: function (up, file) {

                },

                Error: function (up, err) {
                    var responseObj = '', responseMessage = '';
                    try {
                        responseObj = $.parseJSON(err.response);
                        responseMessage = responseObj.message;
                    } catch ($e) {

                    }

                    noty({
                        type: 'error',
                        text: err.message + ' ' + responseMessage,
                        timeout: 800
                    });
                },

                FileUploaded: function (up, file, info) {
                    var responseObj = '', responseMessage = '';
                    try {
                        responseObj = $.parseJSON(info.response);
                        responseMessage = responseObj.message;
                    } catch ($e) {

                    }
                    var imageId = responseObj.data.id;
                    $('#cardf_id').val(imageId);
                    var d = new Date();
                    var imageUrl = "{{route('Api.GetImage.Image',['id'=>'.'])}}/" + imageId + "?" + d.getTime();
                    $('#cardf_img').attr('src', imageUrl);
                }
            }
        });
        uploader.init();

        /*  ------------------上次身份证反面-------------*/
        var uploader2 = new plupload.Uploader({
            runtimes: 'html5,flash,silverlight,html4',
            browse_button: 'cardbBtn',
            url: '{{url('api/upload/image')}}',

            chunk_size: '20mb',
            filters: {
                max_file_size: '10mb',
                mime_types: [
                    {title: "Image files", extensions: "jpg,gif,png"}
                ],
                prevent_duplicates: false
            },
            multi_selection: true,
            unique_names: true,

            flash_swf_url: '{{ url('vendor/plupload-2.1.2/Moxie.swf') }}',
            silverlight_xap_url: '{{ url('vendor/plupload-2.1.2/Moxie.xap') }}',

            file_data_name: 'photo',
            headers: {
                Accept: 'application/json'
            },

            multipart_params: {
                _token: '{{ csrf_token() }}'
            },

            init: {
                PostInit: function () {
                },

                FilesAdded: function (up, files) {
                    up.start();
                },

                BeforeUpload: function (up, file) {
                    up.settings.multipart_params.file_name = file.name;
                },

                UploadProgress: function (up, file) {

                },

                Error: function (up, err) {
                    var responseObj = '', responseMessage = '';
                    try {
                        responseObj = $.parseJSON(err.response);
                        responseMessage = responseObj.message;
                    } catch ($e) {

                    }

                    noty({
                        type: 'error',
                        text: err.message + ' ' + responseMessage,
                        timeout: 800
                    });
                },

                FileUploaded: function (up, file, info) {
                    var responseObj = '', responseMessage = '';
                    try {
                        responseObj = $.parseJSON(info.response);
                        responseMessage = responseObj.message;
                    } catch ($e) {

                    }
                    var imageId = responseObj.data.id;
                    $('#cardb_id').val(imageId);
                    var d = new Date();
                    var imageUrl = "{{route('Api.GetImage.Image',['id'=>'.'])}}/" + imageId + "?" + d.getTime();
                    $('#cardb_img').attr('src', imageUrl);
                }
            }
        });
        uploader2.init();
    </script>
@endsection